<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
        
        // function Child() {} //孩子
        // Grand.prototype.tskill = '拉二胡';
        // // Grand.prototype.hskill = '弹琴';
        // // Grand.prototype.Intro = () => { console.log('I am grandpa');}
        // // //Parent.prototype.mskill = '吃饭'  //失效
        // // //原型重写
        
        // var grand = new Grand();

        // Parent.prototype = grand;
        
        // var parent = new Parent();
        // Parent.prototype.tskill = '弹琴';
       
        // // //添加属性,必须在重写之后
        // // Parent.prototype.mskill = '做饭';
       
        
        // console.log(parent.tskill);
        // console.log(grand.tskill);


        //如何让爷爷拉二胡,爸爸弹琴
        function Grand() {}  //爷爷
        function Parent() {} //爸爸
        Grand.prototype.tskill = '拉二胡';
        var grand = new Grand();
        // Parent.prototype = grand;
        var parent = new Parent();
        Parent.prototype.tskill = '弹琴';        
        console.log(parent.tskill);//爸爸弹琴
        console.log(grand.tskill);//爷爷拉二胡

        
    </script>
</body>
</html>